package com.zengdw.order.service.impl;

import com.zengdw.order.api.AccountApi;
import com.zengdw.order.api.StorageApi;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zengdw.order.entity.OrderTbl;
import com.zengdw.order.mapper.OrderTblMapper;
import com.zengdw.order.service.OrderTblService;
/**
 * 
 * @author zengdw
 * @createTime 2019/12/24 9:52
 */
@Service
public class OrderTblServiceImpl extends ServiceImpl<OrderTblMapper, OrderTbl> implements OrderTblService{
    @Resource
    private StorageApi storageApi;
    @Resource
    private AccountApi accountApi;

    @Override
    @GlobalTransactional(name = "fbs_tx_group", rollbackFor = Exception.class)
    public void index() throws Exception {
        storageApi.update(1, 1);

        accountApi.update(1, 1);

        OrderTbl tbl = new OrderTbl();
        tbl.setCount(1);
        tbl.setMoney(1);
        tbl.setUserId("1");
        baseMapper.insert(tbl);

        throw new Exception("");
    }
}
